﻿Public Class FormProcessed
    Public ty As String
    Public usr As String
    Public current_procedure_No As Integer
    Public current_procedure_Name As String
    Dim objGtProcedureOperatedDetails As New clsGtProcedureOperatedDetails
    Dim objGtProcedure As New clsGtProcedure
    Dim dt As DataTable
    Private Sub FormProcessed_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Text = current_procedure_Name & Me.Text
        GroupBox1.Text = current_procedure_Name & GroupBox1.Text
        setDgvData()
    End Sub

    Public Sub setDgvData()
        dt = objGtProcedureOperatedDetails.getGtProcedureOperatedDetialsLast(ty, "'1'", current_procedure_No.ToString()， 0)
        dt.Columns.Add("oper_type_name")
        If dt.Rows.Count > 0 Then
            For Each row As DataRow In dt.Rows
                If row("oper_type") = "0" Then
                    row("oper_type_name") = "骨架板"
                Else
                    row("oper_type_name") = "法兰板"
                End If
            Next
        End If
        dgv.AutoGenerateColumns = False
        dgv.DataSource = dt
    End Sub
    Private Sub dgv_SelectionChanged(sender As Object, e As EventArgs) Handles dgv.SelectionChanged
        If dgv.SelectedRows.Count > 0 Then
            'Dim postsysid As String
            'Dim sysId As String = dgv.SelectedRows(0).Cells("sys_id").Value.ToString()
            'If dgv.SelectedRows(0).Cells("Col_b_gt_sys_id").Value = Nothing Then
            '    postsysid = sysId
            'Else
            '    postsysid = dgv.SelectedRows(0).Cells("Col_b_gt_sys_id").Value.ToString()
            'End If

            'Dim dtGtProcedure As DataTable = objGtProcedure.getGtProcedure(postsysid, current_procedure_No.ToString())
            'dgvResult.AutoGenerateColumns = False
            'dgvResult.DataSource = dtGtProcedure
            'Dim dtGtProcedureOkDetails As DataTable = objGtProcedureOkDetails.getGtProcedureOkDetailsList(postsysid, current_procedure_No.ToString())
            'dgvOK.AutoGenerateColumns = False
            'dgvOK.DataSource = dtGtProcedureOkDetails
            'Dim dtGtProcedureNgDetails As DataTable = objGtProcedureNgDetails.getGtProcedureNgDetailsList(postsysid, current_procedure_No.ToString())
            'dtGtProcedureNgDetails.Columns.Add("oper_type_name")
            'dtGtProcedureNgDetails.Columns.Add("validity_name")
            'If dtGtProcedureNgDetails.Rows.Count > 0 Then
            '    For Each row As DataRow In dtGtProcedureNgDetails.Rows
            '        If row("oper_type") = "0" Then
            '            row("oper_type_name") = "骨架板"
            '        Else
            '            row("oper_type_name") = "法兰板"
            '        End If
            '        If row("validity") = "0" Then
            '            row("validity_name") = "无效"
            '        Else
            '            row("validity_name") = "有效"
            '        End If
            '    Next
            'End If
            'dgvNG.AutoGenerateColumns = False
            'dgvNG.DataSource = dtGtProcedureNgDetails
        End If
    End Sub
    Private Sub btnNg_Click(sender As Object, e As EventArgs) Handles btnNg.Click
        If dgv.SelectedRows.Count > 0 Then
            If Integer.Parse(dgv.SelectedRows(0).Cells("ng_num").Value.ToString()).Equals(0) Then
                Dim formNG As New FormNG()
                formNG.ty = "0"
                formNG.current_procedure_No = current_procedure_No
                formNG.current_procedure_Name = "六工位"
                formNG.txt_num_enabled = True
                formNG.origin = "processed"

                Dim sysId As String = dgv.SelectedRows(0).Cells("sys_id").Value.ToString()
                formNG.b_gt_procedure_operated_details_sys_id = sysId
                formNG.b_gt_sys_id = dgv.SelectedRows(0).Cells("Col_b_gt_sys_id").Value.ToString()
                formNG.oper_type = dgv.SelectedRows(0).Cells("oper_type").Value.ToString()
                formNG.oper_type_name = dgv.SelectedRows(0).Cells("oper_type_name").Value.ToString()
                formNG.type_value = dgv.SelectedRows(0).Cells("type_value").Value.ToString()
                formNG.batch_no = dgv.SelectedRows(0).Cells("batch_no").Value.ToString()
                formNG.oper_num = dgv.SelectedRows(0).Cells("oper_num").Value.ToString()
                'If String.IsNullOrEmpty(dgv.SelectedRows(0).Cells("assist_marker").Value.ToString()) = False Then
                '    formNG.assist_marker = dgv.SelectedRows(0).Cells("assist_marker").Value.ToString()
                'End If
                formNG.ShowDialog(Me)
            Else
                MsgBox("不合格数已标记")
            End If

        End If
    End Sub

End Class

Public Class entity_gt_procedure_ok_details
    Public procedure_No As String   ' 工序
    Public ok_num As Integer   ' 合格数量
    Public oper As String   '操作员
    Public validity As String  '有效性
    Public b_gt_procedure_sys_id As Integer  '关联ID
    Public b_gt_sys_id As Integer  '关联ID
End Class